import QtQuick 2.2
import QtQuick.Window 2.1

Window {
    visible: true
    width: 1680
    height: 342

    property int n
    property var arr1:[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]
    property var arr2:[20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20]
    property int regnum:0
    property string  num

    Image{
        id:bkgnd
        anchors.fill: parent
        source: "LIFT/BKGND/FLR_BSD/fixedbkgnd .png"
    }


    Item {
        id:dirItem
        clip:true
        x:340
        y:100
        width: 140
        height: 140
        Image{
            id:dirItem1
            anchors.centerIn: parent
            source: ""
        }
    }

    Item {
        id:flrItem
        clip:true
        x:485
        y:114
        width: 195
        height: 111

        Image{
            id:flrItem1
            anchors.left: parent.left
            anchors.leftMargin:(parent.width-flrItem1.width-flrItem2.width-flrItem3.width)/2;
            fillMode: Image.TileHorizontally
            source: ""
        }
        Image{
            id:flrItem2
            anchors.left: flrItem1.right
            source: ""
        }
        Image{
            id:flrItem3
            anchors.left: flrItem2.right
            source: ""
        }

    }

    Item {
        id:regflrItem
        clip:true
        x:700+18
        y:0+10
        width: 980-36
        height: 342-20

        Column{

            spacing: 10
            Row{
                spacing: 16
                Image{id:regflrItem1 }
                Image{id:regflrItem2 }
                Image{id:regflrItem3 }
                Image{id:regflrItem4 }
                Image{id:regflrItem5 }
                }

            Row{
                spacing: 16
                Image{id:regflrItem6 }
                Image{id:regflrItem7 }
                Image{id:regflrItem8 }
                Image{id:regflrItem9 }
                Image{id:regflrItem10 }
            }
        }
    }

    function state_c(str)
    {

    }

    function dir_c(num)
    {
        if(num===0)
            dirItem1.source = ""
        else if((num===1)||(num===2))
            dirItem1.source = "LIFT/SYS/DIR/DIR_U0.png"
        else
            dirItem1.source = "LIFT/SYS/DIR/DIR_D0.png"
    }

   function flr_c(num0)
   {
       num= num0;
       var str;
       str=num.substr(0,3);
       if(num.substr(0,1)===' ')
            str=num.substr(1,2)
       if(num.substr(1,1)===' ')
            str=num.substr(2,1)

        if(str.length==0&&str.length>3)
        {
          return;
        }
        if(str.length==1)
        {
          flrItem1.source="LIFT/SYS/FLR/0x"+(str.substr(0,1).charCodeAt()).toString(16).toUpperCase( )+".png";
          flrItem2.source="";
          flrItem3.source="";
        }
        if(str.length==2)
        {
          flrItem1.source="LIFT/SYS/FLR/0x"+(str.substr(0,1).charCodeAt()).toString(16).toUpperCase( )+".png";
          flrItem2.source="LIFT/SYS/FLR/0x"+(str.substr(1,1).charCodeAt()).toString(16).toUpperCase( )+".png";
          flrItem3.source="";
        }
        if(str.length==3)
        {
          flrItem1.source="LIFT/SYS/FLR/0x"+(str.substr(0,1).charCodeAt()).toString(16).toUpperCase( )+".png";
          flrItem2.source="LIFT/SYS/FLR/0x"+(str.substr(1,1).charCodeAt()).toString(16).toUpperCase( )+".png";
          flrItem3.source="LIFT/SYS/FLR/0x"+(str.substr(2,1).charCodeAt()).toString(16).toUpperCase( )+".png";
        }
   }

   function regflr_c(num)
   {
       if(num==1)
       {
           for(var v=0; v<arr1.length; v++)
           {
               arr1[v]=false
               arr2[v]=20

           }
           regnum=0
           regflrItem1.source=""
           regflrItem2.source=""
           regflrItem3.source=""
           regflrItem4.source=""
           regflrItem5.source=""
           regflrItem6.source=""
           regflrItem7.source=""
           regflrItem8.source=""
           regflrItem9.source=""
           regflrItem10.source=""
       }

       num = num%28+1
       if(regnum>=10)
           return
       else if(regnum==0)
       {
            if(!arr1[num])
            {
                    regflrItem1.source="LIFT/SYS/DATETME/"+num.toString()+".png"
                    arr1[num]=true
                    arr2[num]=0
                    regnum++
            }
       }
       else if(regnum==1)
       {
            if(!arr1[num])
            {
                    regflrItem2.source="LIFT/SYS/DATETME/"+num.toString()+".png"
                    arr1[num]=true
                    arr2[num]=1
                    regnum++
            }
       }
       else if(regnum==2)
       {
            if(!arr1[num])
            {
                    regflrItem3.source="LIFT/SYS/DATETME/"+num.toString()+".png"
                    arr1[num]=true
                    arr2[num]=2
                    regnum++
            }
       }
       else if(regnum==3)
       {
            if(!arr1[num])
            {
                    regflrItem4.source="LIFT/SYS/DATETME/"+num.toString()+".png"
                    arr1[num]=true
                    arr2[num]=3
                    regnum++
            }
       }
       else if(regnum==4)
       {
            if(!arr1[num])
            {
                    regflrItem5.source="LIFT/SYS/DATETME/"+num.toString()+".png"
                    arr1[num]=true
                    arr2[num]=4
                    regnum++
            }
       }
       else if(regnum==5)
       {
            if(!arr1[num])
            {
                    regflrItem6.source="LIFT/SYS/DATETME/"+num.toString()+".png"
                    arr1[num]=true
                    arr2[num]=5
                    regnum++
            }
       }
       else if(regnum==6)
       {
            if(!arr1[num])
            {
                    regflrItem7.source="LIFT/SYS/DATETME/"+num.toString()+".png"
                    arr1[num]=true
                    arr2[num]=6
                    regnum++
            }
       }
       else if(regnum==7)
       {
            if(!arr1[num])
            {
                    regflrItem8.source="LIFT/SYS/DATETME/"+num.toString()+".png"
                    arr1[num]=true
                    arr2[num]=7
                    regnum++
            }
       }
       else if(regnum==8)
       {
            if(!arr1[num])
            {
                    regflrItem9.source="LIFT/SYS/DATETME/"+num.toString()+".png"
                    arr1[num]=true
                    arr2[num]=8
                    regnum++
            }
       }
       else if(regnum==9)
       {
            if(!arr1[num])
            {
                    regflrItem10.source="LIFT/SYS/DATETME/"+num.toString()+".png"
                    arr1[num]=true
                    arr2[num]=9
                    regnum++
            }
       }

   }

   function unregflr_c(num)
   {
       if(num==1)
       {
           for(var v=0; v<arr1.length; v++)
           {
               arr1[v]=false
               arr2[v]=20

           }
           regnum=0
           regflrItem1.source=""
           regflrItem2.source=""
           regflrItem3.source=""
           regflrItem4.source=""
           regflrItem5.source=""
           regflrItem6.source=""
           regflrItem7.source=""
           regflrItem8.source=""
           regflrItem9.source=""
           regflrItem10.source=""
       }

        num = num%28+1
        if(arr1[num])
        {
                findpos(num)
                arr1[num]=false
        }
   }

   function findpos(num)
   {
       var rn = arr2[num]
       if(rn==20)
           return
       else  if(rn==0)
       {
           regflrItem1.source=""
           regnum--
       }
       else  if(rn==1)
       {
           regflrItem2.source=""
           regnum--
       }
       else  if(rn==2)
       {
           regflrItem3.source=""
           regnum--
       }
       else  if(rn==3)
       {
           regflrItem4.source=""
           regnum--
       }
       else  if(rn==4)
       {
           regflrItem5.source=""
           regnum--
       }
       else  if(rn==5)
       {
           regflrItem6.source=""
           regnum--
       }
       else  if(rn==6)
       {
           regflrItem7.source=""
           regnum--
       }
       else  if(rn==7)
       {
           regflrItem8.source=""
           regnum--
       }
       else  if(rn==8)
        {
           regflrItem9.source=""
           regnum--
       }
       else  if(rn==9)
       {
           regflrItem10.source=""
           regnum--
       }

       arr2[num]=20

   }

}
